package org.dlx.drpc.core.common;

import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToMessageDecoder;

import java.util.List;

public class RPCDecoder extends MessageToMessageDecoder<Message>
{
    private IRPCDecoder decoder;

    public RPCDecoder(IRPCDecoder e){
        this.decoder = e;
    }
    @Override
    protected void decode(ChannelHandlerContext ctx, Message msg, List<Object> out) throws Exception {
        if(this.decoder == null)
            return;
        out.add(this.decoder.decode(msg.getPayload()));
    }
}
